package com.rd.student.jike.class2.xuezhixin.day0808;

import java.io.File;
import java.io.FileReader;
import java.io.Reader;
import java.util.Scanner;

public class Work02 {
    public static void main(String[] args) throws Exception{
        File file = new File("player.txt");
        Reader reader = new FileReader(file);
        char[] chars = new char[(int) file.length()];
        reader.read(chars);
        String strAll = new String(chars);
        String[] strs = strAll.split("\n");

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入您要查询的球员姓名：");
        String name = scanner.next();

        int num = name.length();
        boolean b = true;
        for (String str : strs){
            String strName = "";
            String strTeam = "";
            for (int i = 0;i<num;i++){
                strName += str.charAt(i);
            }
            for (int i = num+1;i<str.length();i++){
                strTeam += str.charAt(i);
            }
            if (strName.equals(name)){
                System.out.println(name + "属于" + strTeam);
                b = false;
                break;
            }
        }
        if (b){
            System.out.println("不存在该球员");
        }

        reader.close();
    }
}
